package com.green.common.fusionchart;

import java.util.ArrayList;
import java.util.List;

import com.green.common.fusionchart.enums.DefaultColorEnum;
import com.green.common.fusionchart.enums.ParentYAxisEnum;
import com.green.common.fusionchart.enums.RenderAsEnum;
/**
 * (如果未设置parentYAxis属性时)第一个dataset为Y主轴  第二个dataset数据为Y副轴  默认为线
 * @author Administrator
 *
 */
public class MSCombiDY2D extends Column2D {
	// Y副轴是否格式化
	private Boolean sFormatNumber;

	private Boolean sFormatNumberScale;

	private Boolean forceSYAxisValueDecimals = true;

	private String sNumberPrefix;

	private String sNumberSuffix = "%";

	private Integer sDecimals = 2;

	private Integer sYAxisValueDecimals = 2;


	public Boolean getsFormatNumber() {
		return sFormatNumber;
	}

	public void setsFormatNumber(Boolean sFormatNumber) {
		this.sFormatNumber = sFormatNumber;
	}

	public Boolean getsFormatNumberScale() {
		return sFormatNumberScale;
	}

	public void setsFormatNumberScale(Boolean sFormatNumberScale) {
		this.sFormatNumberScale = sFormatNumberScale;
	}

	public Boolean getForceSYAxisValueDecimals() {
		return forceSYAxisValueDecimals;
	}

	public void setForceSYAxisValueDecimals(Boolean forceSYAxisValueDecimals) {
		this.forceSYAxisValueDecimals = forceSYAxisValueDecimals;
	}

	public String getsNumberPrefix() {
		return sNumberPrefix;
	}

	public void setsNumberPrefix(String sNumberPrefix) {
		this.sNumberPrefix = sNumberPrefix;
	}

	public String getsNumberSuffix() {
		return sNumberSuffix;
	}

	public void setsNumberSuffix(String sNumberSuffix) {
		this.sNumberSuffix = sNumberSuffix;
	}

	public Integer getsDecimals() {
		return sDecimals;
	}

	public void setsDecimals(Integer sDecimals) {
		this.sDecimals = sDecimals;
	}

	public Integer getsYAxisValueDecimals() {
		return sYAxisValueDecimals;
	}

	public void setsYAxisValueDecimals(Integer sYAxisValueDecimals) {
		this.sYAxisValueDecimals = sYAxisValueDecimals;
	}
	public void setDataSets(List<DataSet> dataSets,
			List<DefaultColorEnum> colors) {
		setColorForSet(dataSets, colors);
		super.setDataSets(dataSets);
	}
	
	public void setDataSets(List<DataSet> dataSets){
		setColorForSet(dataSets, null);
		super.setDataSets(dataSets);
	}

	public void setColorForSet(List<DataSet> sets, List<DefaultColorEnum> colors) {
		if (colors == null || colors.size() == 0) {
			colors = new ArrayList<DefaultColorEnum>();
			for (DefaultColorEnum color : DefaultColorEnum.values()) {
				colors.add(color);
			}
		}
		int i = 0;
		int j = 0;
		for (DataSet set : sets) {
			set.setColor(colors.get(i).getColor());
			if(j == 0){
				if(set.getParentYAxis() == null){
					set.setParentYAxis(ParentYAxisEnum.P);
				}
			}else if(j == 1){
				if(set.getParentYAxis() == null){
					set.setParentYAxis(ParentYAxisEnum.S);
				}
				if(set.getRenderAs() == null)
					set.setRenderAs(RenderAsEnum.LINE);
			}
			i++;
			j++;
			if (i == colors.size())
				i = 0;
		}
	}
}
